package fields;

import java.awt.geom.Point2D;

public class Charge {
    Point2D point;
    double charge;
    double vx;
    double vy;

    public Charge(Point2D point, double charge) {
        this.point = point;
        this.charge = charge;
    }

    public double getVx() {
        return vx;
    }

    public void setVx(double vx) {
        this.vx = vx;
    }

    public double getVy() {
        return vy;
    }

    public void setVy(double vy) {
        this.vy = vy;
    }

    public Point2D getPoint() {
        return point;
    }

    public double getCharge() {
        return charge;
    }

    public double[] getF(Point2D p) {
        double r2 = (point.getX() - p.getX()) * (point.getX() - p.getX()) + (point.getY() - p.getY()) * (point.getY() - p.getY());
        double r3 = /*Math.exp(1.5 * Math.log(r2))*/r2 * Math.sqrt(r2);
        double fx = charge * (point.getX() - p.getX()) / r3;
        double fy = charge * (point.getY() - p.getY()) / r3;
        return new double[]{fx, fy};
    }

    public double[] getFNorm(Point2D p) {
        double[] f = getF(p);
        Util.norm(f);
        return f;
    }
}
